import axios from 'axios';
import base from '_common/services/base';
const apiUrl = base.test;
import {setCookie} from '@/utils/cookiesUtil.js'

export default function getOauth() {
  setCookie('token', '');
  const url = window.location.href;
  axios({
    url: `${apiUrl}/nu/anon/user/oauth2/authorize`,
    method: 'post',
    data: {
      number: 1,
      type: 2,
      destination: `${url.split('code=')[0].split('state=')[0]}`,
    },
  }).then(res => {
    if (res.data && res.data.code === 0) {
      location.href = res.data.data.url;
    }
  });
}